package com.woniu.smallmedical.server.serverimpl;


import com.woniu.smallmedical.entity.User;
import com.woniu.smallmedical.mapper.UserMapper;
import com.woniu.smallmedical.server.UserServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class UserServerImpl implements UserServer {
    @Autowired
    UserMapper userMapper;

    @Override
    public List<User> getDoctorByDid(int did) {
        List<User> doctorByDid = userMapper.getDoctorByDid(did);
        return doctorByDid;
    }

	@Override
	public User login(String sname, String password) {
		User user = userMapper.login(sname, password);
		return user;
	}

	@Override
	public List<User> getUserPage(int pagesize, int pageIndex,String query) {
    	List<User> getUserPage = userMapper.getUserPage(pagesize, pageIndex,query);
		return getUserPage;
	}

	@Override
	public List<User> getAllUsers() {
    	List<User> getAllUsers = userMapper.getAllUsers();
		return getAllUsers;
	}

	@Override
	public int getCounts() {
		return userMapper.getCounts();
	}

	@Override
	public List<User> getDoctors() {
		List<User> doctors = userMapper.getDoctors();
		return doctors;
	}

	@Override
	public List<User> getUserPageNoQuery(int pagesize, int pageIndex) {
		List<User> getUserPageNoQuery = userMapper.getUserPageNoQuery(pagesize, pageIndex);
		return getUserPageNoQuery;
	}

	@Override
	public User getUser(String username) {
    	User user = userMapper.getUser(username);
		return user;
	}

	@Override
	public int changePassword(String username, String password, String newpassword) {

		int num = userMapper.changePassword(username,password,newpassword);


		return num;
	}

	@Override
	public int changeUserInfo(String username, String semail, String stel, String add,int sid) {
		int count = userMapper.changeUserInfo(username,semail,stel,add,sid);

    	return count;
	}

	@Override
	public int addUser(String username, String snum, int sage, String sex, String semail, String stel, String add,int did, int rid) {
		int count = userMapper.addUser(username, snum, sage, sex, semail, stel, add, did, rid);

    	return count;
	}

	@Override
//	public int changeUserListInfo(String username, String snum, int sage, String sex, String semail, String stel, String add, int did, int rid, int sid) {
//		int count = userMapper.changeUserListInfo(username, snum, sage, sex, semail, stel, add, did, rid,sid);
//
//    	return count;
//	}
	public int changeUserListInfo(User user){
    	int count = userMapper.changeUserListInfo(user);
    	return count;
	}

	@Override
	public int deleteUser(int sid) {
    	int count = userMapper.deleteUser(sid);
		return count;
	}

}
